// This example shows how to read data (value, timestamps, and status code) of 3 attributes at once. In this example, // we are reading a Value attribute of 3 different nodes, but the method can also be used to read multiple attributes // of the same node. // // Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html . // OPC client and subscriber examples in C# on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-CSharp . // Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own // a commercial license in order to use Online Forums, and we reply to every post. using System; using OpcLabs.EasyOpc.UA; using OpcLabs.EasyOpc.UA.OperationModel; namespace UADocExamples._EasyUAClient { partial class ReadMultiple { public static void Main1() { UAEndpointDescriptor endpointDescriptor = "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer"; // or "http://opcua.demo-this.com:51211/UA/SampleServer" (currently not supported) // or "https://opcua.demo-this.com:51212/UA/SampleServer/" // Instantiate the client object. var client = new EasyUAClient(); // Obtain attribute data. By default, the Value attributes of the nodes will be read. UAAttributeDataResult[] attributeDataResultArray = client.ReadMultiple(new[] { new UAReadArguments(endpointDescriptor, "nsu=http://test.org/UA/Data/ ;i=10845"), new UAReadArguments(endpointDescriptor, "nsu=http://test.org/UA/Data/ ;i=10853"), new UAReadArguments(endpointDescriptor, "nsu=http://test.org/UA/Data/ ;i=10855") }); // Display results. foreach (UAAttributeDataResult attributeDataResult in attributeDataResultArray) { if (attributeDataResult.Succeeded) Console.WriteLine($"AttributeData: {attributeDataResult.AttributeData}"); else Console.WriteLine($"*** Failure: {attributeDataResult.ErrorMessageBrief}"); } } // Example output: // //AttributeData: 51 {Int16} @11/6/2011 1:49:19 PM @11/6/2011 1:49:19 PM; Good //AttributeData: -1993984 {Single} @11/6/2011 1:49:19 PM @11/6/2011 1:49:19 PM; Good //AttributeData: Yellow% Dragon Cat) White Blue Dog# Green Banana- {String} @11/6/2011 1:49:19 PM @11/6/2011 1:49:19 PM; Good } }
# This example shows how to read data (value, timestamps, and status code) of 3 attributes at once. In this example, # we are reading a Value attribute of 3 different nodes, but the method can also be used to read multiple attributes # of the same node. # # Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html . # OPC client and subscriber examples in PowerShell on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-PowerShell . # Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own # a commercial license in order to use Online Forums, and we reply to every post. #requires -Version 5.1 using namespace OpcLabs.EasyOpc.UA using namespace OpcLabs.EasyOpc.UA.OperationModel # The path below assumes that the current directory is [ProductDir]/Examples-NET/PowerShell/Windows . Add-Type -Path "../../../Components/Opclabs.QuickOpc/net472/OpcLabs.EasyOpcUA.dll" Add-Type -Path "../../../Components/Opclabs.QuickOpc/net472/OpcLabs.EasyOpcUAComponents.dll" [UAEndpointDescriptor]$endpointDescriptor = "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer" # or "http://opcua.demo-this.com:51211/UA/SampleServer" (currently not supported) # or "https://opcua.demo-this.com:51212/UA/SampleServer/" # Instantiate the client object. $client = New-Object EasyUAClient # Obtain attribute data. By default, the Value attributes of the nodes will be read. $attributeDataResultArray = $client.ReadMultiple(@( (New-Object UAReadArguments($endpointDescriptor, "nsu=http://test.org/UA/Data/ ;i=10845")), (New-Object UAReadArguments($endpointDescriptor, "nsu=http://test.org/UA/Data/ ;i=10853")), (New-Object UAReadArguments($endpointDescriptor, "nsu=http://test.org/UA/Data/ ;i=10855")) )) foreach ($attributeDataResult in $attributeDataResultArray) { if ($attributeDataResult.Succeeded) { Write-Host "AttributeData: $($attributeDataResult.AttributeData)" } else { Write-Host "*** Failure: $($attributeDataResult.ErrorMessageBrief)" } } # Example output: # #AttributeData: 51 {Int16} @11/6/2011 1:49:19 PM @11/6/2011 1:49:19 PM; Good #AttributeData: -1993984 {Single} @11/6/2011 1:49:19 PM @11/6/2011 1:49:19 PM; Good #AttributeData: Yellow% Dragon Cat) White Blue Dog# Green Banana- {String} @11/6/2011 1:49:19 PM @11/6/2011 1:49:19 PM; Good
' This example shows how to read data (value, timestamps, and status code) of 3 attributes at once. In this example, ' we are reading a Value attribute of 3 different nodes, but the method can also be used to read multiple attributes ' of the same node. ' ' Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html . ' OPC client and subscriber examples in VB.NET on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-VBNET . ' Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own ' a commercial license in order to use Online Forums, and we reply to every post. Imports OpcLabs.EasyOpc.UA Imports OpcLabs.EasyOpc.UA.OperationModel Namespace _EasyUAClient Partial Friend Class ReadMultiple Public Shared Sub Main1() ' Define which server we will work with. Dim endpointDescriptor As UAEndpointDescriptor = "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer" ' or "http://opcua.demo-this.com:51211/UA/SampleServer" (currently not supported) ' or "https://opcua.demo-this.com:51212/UA/SampleServer/" ' Instantiate the client object Dim client = New EasyUAClient() ' Obtain attribute data. By default, the Value attributes of the nodes will be read. Dim attributeDataResultArray() As UAAttributeDataResult = client.ReadMultiple(New UAReadArguments() _ { New UAReadArguments(endpointDescriptor, "nsu=http://test.org/UA/Data/ ;i=10845"), New UAReadArguments(endpointDescriptor, "nsu=http://test.org/UA/Data/ ;i=10853"), New UAReadArguments(endpointDescriptor, "nsu=http://test.org/UA/Data/ ;i=10855") }) ' Display results For Each attributeDataResult As UAAttributeDataResult In attributeDataResultArray If attributeDataResult.Succeeded Then Console.WriteLine("AttributeData: {0}", attributeDataResult.AttributeData) Else Console.WriteLine("*** Failure: {0}", attributeDataResult.ErrorMessageBrief) End If Next attributeDataResult ' Example output: ' 'AttributeData: 51 {System.Int16} @11/6/2011 1:49:19 PM @11/6/2011 1:49:19 PM; Good 'AttributeData: -1993984 {System.Single} @11/6/2011 1:49:19 PM @11/6/2011 1:49:19 PM; Good 'AttributeData: Yellow% Dragon Cat) White Blue Dog# Green Banana- {System.String} @11/6/2011 1:49:19 PM @11/6/2011 1:49:19 PM; Good End Sub End Class End Namespace
// This example shows how to read the attributes of 4 OPC-UA nodes at once, and display the results. // // Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html . // Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own // a commercial license in order to use Online Forums, and we reply to every post. #include "stdafx.h" // Includes "QuickOpc.h", and other commonly used files #include <atlsafe.h> #include "ReadMultiple.h" namespace _EasyUAClient { void ReadMultiple::Main() { // Initialize the COM library CoInitializeEx(NULL, COINIT_MULTITHREADED); { _UAReadArgumentsPtr ReadArguments1Ptr(_uuidof(UAReadArguments)); ReadArguments1Ptr->EndpointDescriptor->UrlString = //L"http://opcua.demo-this.com:51211/UA/SampleServer"; L"opc.tcp://opcua.demo-this.com:51210/UA/SampleServer"; ReadArguments1Ptr->NodeDescriptor->NodeId->ExpandedText = L"nsu=http://test.org/UA/Data/ ;i=10853"; _UAReadArgumentsPtr ReadArguments2Ptr(_uuidof(UAReadArguments)); ReadArguments2Ptr->EndpointDescriptor->UrlString = //L"http://opcua.demo-this.com:51211/UA/SampleServer"; L"opc.tcp://opcua.demo-this.com:51210/UA/SampleServer"; ReadArguments2Ptr->NodeDescriptor->NodeId->ExpandedText = L"nsu=http://test.org/UA/Data/ ;i=10845"; _UAReadArgumentsPtr ReadArguments3Ptr(_uuidof(UAReadArguments)); ReadArguments3Ptr->EndpointDescriptor->UrlString = //L"http://opcua.demo-this.com:51211/UA/SampleServer"; L"opc.tcp://opcua.demo-this.com:51210/UA/SampleServer"; ReadArguments3Ptr->NodeDescriptor->NodeId->ExpandedText = L"nsu=http://test.org/UA/Data/ ;i=10304"; _UAReadArgumentsPtr ReadArguments4Ptr(_uuidof(UAReadArguments)); ReadArguments4Ptr->EndpointDescriptor->UrlString = //L"http://opcua.demo-this.com:51211/UA/SampleServer"; L"opc.tcp://opcua.demo-this.com:51210/UA/SampleServer"; ReadArguments4Ptr->NodeDescriptor->NodeId->ExpandedText = L"nsu=http://test.org/UA/Data/ ;i=10389"; CComSafeArray<VARIANT> arguments(4); arguments.SetAt(0, _variant_t((IDispatch*)ReadArguments1Ptr)); arguments.SetAt(1, _variant_t((IDispatch*)ReadArguments2Ptr)); arguments.SetAt(2, _variant_t((IDispatch*)ReadArguments3Ptr)); arguments.SetAt(3, _variant_t((IDispatch*)ReadArguments4Ptr)); CComVariant vArguments(arguments); // Instantiate the client object _EasyUAClientPtr ClientPtr(__uuidof(EasyUAClient)); // Obtain values. By default, the Value attributes of the nodes will be read. CComSafeArray<VARIANT> results; results.Attach(ClientPtr->ReadMultiple(&vArguments)); // Display results for (int i = results.GetLowerBound(); i <= results.GetUpperBound(); i++) { _UAAttributeDataResultPtr ResultPtr = results[i]; _variant_t vString; vString.ChangeType(VT_BSTR, &_variant_t((IDispatch*)ResultPtr->AttributeData)); _tprintf(_T("results(d).AttributeDatas\n"), i, (LPCTSTR)CW2CT((_bstr_t)vString)); } } // Release all interface pointers BEFORE calling CoUninitialize() CoUninitialize(); } }
// This example shows how to read the attributes of 4 OPC-UA nodes at once, and // display the results. // // Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html . // OPC client and subscriber examples in Object Pascal (Delphi) on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-OP . // Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own // a commercial license in order to use Online Forums, and we reply to every post. class procedure ReadMultiple.Main; var Arguments: OleVariant; Client: OpcLabs_EasyOpcUA_TLB._EasyUAClient; I: Cardinal; ReadArguments1, ReadArguments2, ReadArguments3, ReadArguments4: _UAReadArguments; Result: _UAAttributeDataResult; Results: OleVariant; begin ReadArguments1 := CoUAReadArguments.Create; ReadArguments1.EndpointDescriptor.UrlString := //'http://opcua.demo-this.com:51211/UA/SampleServer'; //'https://opcua.demo-this.com:51212/UA/SampleServer/'; 'opc.tcp://opcua.demo-this.com:51210/UA/SampleServer'; ReadArguments1.NodeDescriptor.NodeId.ExpandedText := 'nsu=http://test.org/UA/Data/ ;i=10853'; ReadArguments2 := CoUAReadArguments.Create; ReadArguments2.EndpointDescriptor.UrlString := //'http://opcua.demo-this.com:51211/UA/SampleServer'; //'https://opcua.demo-this.com:51212/UA/SampleServer/'; 'opc.tcp://opcua.demo-this.com:51210/UA/SampleServer'; ReadArguments2.NodeDescriptor.NodeId.ExpandedText := 'nsu=http://test.org/UA/Data/ ;i=10845'; ReadArguments3 := CoUAReadArguments.Create; ReadArguments3.EndpointDescriptor.UrlString := //'http://opcua.demo-this.com:51211/UA/SampleServer'; //'https://opcua.demo-this.com:51212/UA/SampleServer/'; 'opc.tcp://opcua.demo-this.com:51210/UA/SampleServer'; ReadArguments3.NodeDescriptor.NodeId.ExpandedText := 'nsu=http://test.org/UA/Data/ ;i=10304'; ReadArguments4 := CoUAReadArguments.Create; ReadArguments4.EndpointDescriptor.UrlString := //'http://opcua.demo-this.com:51211/UA/SampleServer'; //'https://opcua.demo-this.com:51212/UA/SampleServer/'; 'opc.tcp://opcua.demo-this.com:51210/UA/SampleServer'; ReadArguments4.NodeDescriptor.NodeId.ExpandedText := 'nsu=http://test.org/UA/Data/ ;i=10389'; Arguments := VarArrayCreate([0, 3], varVariant); Arguments[0] := ReadArguments1; Arguments[1] := ReadArguments2; Arguments[2] := ReadArguments3; Arguments[3] := ReadArguments4; // Instantiate the client object Client := CoEasyUAClient.Create; // Perform the operation TVarData(Results).VType := varArray or varVariant; TVarData(Results).VArray := PVarArray(Client.ReadMultiple(Arguments)); // Display results for I := VarArrayLowBound(Results, 1) to VarArrayHighBound(Results, 1) do begin Result := IInterface(Results[I]) as _UAAttributeDataResult; if Result.Succeeded then WriteLn('results(', I, ').AttributeData: ', Result.AttributeData.ToString) else WriteLn('results(', I, ') *** Failure: ', Result.ErrorMessageBrief); end; VarClear(Results); VarClear(Arguments); end;
// This example shows how to read the attributes of 4 OPC-UA nodes at once, and display the results. // // Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html . // OPC client and subscriber examples in PHP on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-PHP . // Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own // a commercial license in order to use Online Forums, and we reply to every post. $ReadArguments1 = new COM("OpcLabs.EasyOpc.UA.OperationModel.UAReadArguments"); $ReadArguments1->EndpointDescriptor->UrlString = //"http://opcua.demo-this.com:51211/UA/SampleServer"; //"https://opcua.demo-this.com:51212/UA/SampleServer/"; "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer"; $ReadArguments1->NodeDescriptor->NodeId->ExpandedText = "nsu=http://test.org/UA/Data/ ;i=10853"; $ReadArguments2 = new COM("OpcLabs.EasyOpc.UA.OperationModel.UAReadArguments"); $ReadArguments2->EndpointDescriptor->UrlString = //"http://opcua.demo-this.com:51211/UA/SampleServer"; //"https://opcua.demo-this.com:51212/UA/SampleServer/"; "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer"; $ReadArguments2->NodeDescriptor->NodeId->ExpandedText = "nsu=http://test.org/UA/Data/ ;i=10845"; $ReadArguments3 = new COM("OpcLabs.EasyOpc.UA.OperationModel.UAReadArguments"); $ReadArguments3->EndpointDescriptor->UrlString = //"http://opcua.demo-this.com:51211/UA/SampleServer"; //"https://opcua.demo-this.com:51212/UA/SampleServer/"; "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer"; $ReadArguments3->NodeDescriptor->NodeId->ExpandedText = "nsu=http://test.org/UA/Data/ ;i=10304"; $ReadArguments4 = new COM("OpcLabs.EasyOpc.UA.OperationModel.UAReadArguments"); $ReadArguments4->EndpointDescriptor->UrlString = //"http://opcua.demo-this.com:51211/UA/SampleServer"; //"https://opcua.demo-this.com:51212/UA/SampleServer/"; "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer"; $ReadArguments4->NodeDescriptor->NodeId->ExpandedText = "nsu=http://test.org/UA/Data/ ;i=10389"; $arguments[0] = $ReadArguments1; $arguments[1] = $ReadArguments2; $arguments[2] = $ReadArguments3; $arguments[3] = $ReadArguments4; // Instantiate the client object $Client = new COM("OpcLabs.EasyOpc.UA.EasyUAClient"); // Perform the operation $results = $Client->ReadMultiple($arguments); // Display results for ($i = 0; $i < count($results); $i++) { $attributeDataResult = $results[$i]; if ($attributeDataResult->Succeeded) printf("results[d].AttributeDatas\n", $i, $attributeDataResult->AttributeData); else printf("results[d]: *** Failures\n", $i, $attributeDataResult->ErrorMessageBrief); }
// This example shows how to read data (value, timestamps, and status code) of 3 attributes at once. In this example, // we are reading a Value attribute of 3 different nodes, but the method can also be used to read multiple attributes // of the same node. mle_outputtext.Text = "" // Instantiate the client object OLEObject client client = CREATE OLEObject client.ConnectToNewObject("OpcLabs.EasyOpc.UA.EasyUAClient") // Prepare arguments. By default, the Value attributes of the nodes will be read. OLEObject readArguments1 readArguments1 = CREATE OLEObject readArguments1.ConnectToNewObject("OpcLabs.EasyOpc.UA.OperationModel.UAReadArguments") readArguments1.EndpointDescriptor.UrlString = "http://opcua.demo-this.com:51211/UA/SampleServer" readArguments1.NodeDescriptor.NodeId.ExpandedText = "nsu=http://test.org/UA/Data/ ;i=10845" OLEObject readArguments2 readArguments2 = CREATE OLEObject readArguments2.ConnectToNewObject("OpcLabs.EasyOpc.UA.OperationModel.UAReadArguments") readArguments2.EndpointDescriptor.UrlString = "http://opcua.demo-this.com:51211/UA/SampleServer" readArguments2.NodeDescriptor.NodeId.ExpandedText = "nsu=http://test.org/UA/Data/ ;i=10853" OLEObject readArguments3 readArguments3 = CREATE OLEObject readArguments3.ConnectToNewObject("OpcLabs.EasyOpc.UA.OperationModel.UAReadArguments") readArguments3.EndpointDescriptor.UrlString = "http://opcua.demo-this.com:51211/UA/SampleServer" readArguments3.NodeDescriptor.NodeId.ExpandedText = "nsu=http://test.org/UA/Data/ ;i=10855" OLEObject readArgumentsList readArgumentsList = CREATE OLEObject readArgumentsList.ConnectToNewObject("OpcLabs.BaseLib.Collections.ElasticVector") readArgumentsList.Add(readArguments1) readArgumentsList.Add(readArguments2) readArgumentsList.Add(readArguments3) // Obtain attribute data. OLEObject attributeDataResultList attributeDataResultList = client.ReadList(readArgumentsList) // Display results Int i FOR i = 0 TO attributeDataResultList.Count - 1 OLEObject attributeDataResult attributeDataResult = attributeDataResultList.Item[i] IF attributeDataResult.Succeeded THEN mle_outputtext.Text = mle_outputtext.Text + "AttributeData: " + String(attributeDataResult.AttributeData) + "~r~n" ELSE mle_outputtext.Text = mle_outputtext.Text + "*** Failure: " + attributeDataResult.ErrorMessageBrief + "~r~n" END IF NEXT // Example output: // //AttributeData: 51 {System.Int16} @11/6/2011 1:49:19 PM @11/6/2011 1:49:19 PM; Good //AttributeData: -1993984 {System.Single} @11/6/2011 1:49:19 PM @11/6/2011 1:49:19 PM; Good //AttributeData: Yellow% Dragon Cat) White Blue Dog# Green Banana- {System.String} @11/6/2011 1:49:19 PM @11/6/2011 1:49:19 PM; Good
REM This example shows how to read the attributes of 4 OPC-UA nodes at once, and REM display the results. REM REM Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html . REM OPC client and subscriber examples in Visual Basic on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-VB . REM Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own REM a commercial license in order to use Online Forums, and we reply to every post. Public Sub ReadMultiple_Main_Command_Click() OutputText = "" Dim readArguments1 As New UAReadArguments readArguments1.endpointDescriptor.UrlString = "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer" readArguments1.nodeDescriptor.NodeId.expandedText = "nsu=http://test.org/UA/Data/ ;i=10853" Dim ReadArguments2 As New UAReadArguments ReadArguments2.endpointDescriptor.UrlString = "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer" ReadArguments2.nodeDescriptor.NodeId.expandedText = "nsu=http://test.org/UA/Data/ ;i=10845" Dim ReadArguments3 As New UAReadArguments ReadArguments3.endpointDescriptor.UrlString = "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer" ReadArguments3.nodeDescriptor.NodeId.expandedText = "nsu=http://test.org/UA/Data/ ;i=10304" Dim ReadArguments4 As New UAReadArguments ReadArguments4.endpointDescriptor.UrlString = "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer" ReadArguments4.nodeDescriptor.NodeId.expandedText = "nsu=http://test.org/UA/Data/ ;i=10389" Dim arguments(3) As Variant Set arguments(0) = readArguments1 Set arguments(1) = ReadArguments2 Set arguments(2) = ReadArguments3 Set arguments(3) = ReadArguments4 ' Instantiate the client object Dim Client As New EasyUAClient ' Obtain values. By default, the Value attributes of the nodes will be read. Dim results() As Variant results = Client.ReadMultiple(arguments) ' Display results Dim i: For i = LBound(results) To UBound(results) Dim Result As UAAttributeDataResult: Set Result = results(i) If Result.Succeeded Then OutputText = OutputText & "results(" & i & ").AttributeData: " & Result.AttributeData & vbCrLf Else OutputText = OutputText & "results(" & i & ") *** Failure: " & Result.ErrorMessageBrief & vbCrLf End If Next End Sub
Rem This example shows how to read the attributes of 4 OPC-UA nodes at once, and display the results. Rem Rem Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html . Rem OPC client and subscriber examples in VBScript on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-VBScript . Rem Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own Rem a commercial license in order to use Online Forums, and we reply to every post. Option Explicit Dim ReadArguments1: Set ReadArguments1 = CreateObject("OpcLabs.EasyOpc.UA.OperationModel.UAReadArguments") ReadArguments1.EndpointDescriptor.UrlString = "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer" ReadArguments1.NodeDescriptor.NodeId.ExpandedText = "nsu=http://test.org/UA/Data/ ;i=10853" Dim ReadArguments2: Set ReadArguments2 = CreateObject("OpcLabs.EasyOpc.UA.OperationModel.UAReadArguments") ReadArguments2.EndpointDescriptor.UrlString = "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer" ReadArguments2.NodeDescriptor.NodeId.ExpandedText = "nsu=http://test.org/UA/Data/ ;i=10845" Dim ReadArguments3: Set ReadArguments3 = CreateObject("OpcLabs.EasyOpc.UA.OperationModel.UAReadArguments") ReadArguments3.EndpointDescriptor.UrlString = "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer" ReadArguments3.NodeDescriptor.NodeId.ExpandedText = "nsu=http://test.org/UA/Data/ ;i=10304" Dim ReadArguments4: Set ReadArguments4 = CreateObject("OpcLabs.EasyOpc.UA.OperationModel.UAReadArguments") ReadArguments4.EndpointDescriptor.UrlString = "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer" ReadArguments4.NodeDescriptor.NodeId.ExpandedText = "nsu=http://test.org/UA/Data/ ;i=10389" Dim arguments(3) Set arguments(0) = ReadArguments1 Set arguments(1) = ReadArguments2 Set arguments(2) = ReadArguments3 Set arguments(3) = ReadArguments4 ' Instantiate the client object Dim Client: Set Client = CreateObject("OpcLabs.EasyOpc.UA.EasyUAClient") ' Perform the operation Dim results: results = Client.ReadMultiple(arguments) ' Display results Dim i: For i = LBound(results) To UBound(results) Dim AttributeDataResult: Set AttributeDataResult = results(i) If AttributeDataResult.Succeeded Then WScript.Echo "results(" & i & ").AttributeData: " & AttributeDataResult.AttributeData Else WScript.Echo "results(" & i & ") *** Failure: " & AttributeDataResult.ErrorMessageBrief End If Next
# This example shows how to read data (value, timestamps, and status code) of 3 attributes at once. In this example, # we are reading a Value attribute of 3 different nodes, but the method can also be used to read multiple attributes # of the same node. # # Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html . # OPC client and subscriber examples in Python on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-Python . # Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own # a commercial license in order to use Online Forums, and we reply to every post. # The QuickOPC package is needed. Install it using "pip install opclabs_quickopc". import opclabs_quickopc import time # Import .NET namespaces. from OpcLabs.EasyOpc.UA import * from OpcLabs.EasyOpc.UA.OperationModel import * endpointDescriptor = UAEndpointDescriptor('opc.tcp://opcua.demo-this.com:51210/UA/SampleServer') # or 'http://opcua.demo-this.com:51211/UA/SampleServer' (currently not supported) # or 'https://opcua.demo-this.com:51212/UA/SampleServer/' # Instantiate the client object. client = EasyUAClient() # Obtain attribute data. By default, the Value attributes of the nodes will be read. attributeDataResultArray = client.ReadMultiple([ UAReadArguments(endpointDescriptor, UANodeDescriptor('nsu=http://test.org/UA/Data/ ;i=10845')), UAReadArguments(endpointDescriptor, UANodeDescriptor('nsu=http://test.org/UA/Data/ ;i=10853')), UAReadArguments(endpointDescriptor, UANodeDescriptor('nsu=http://test.org/UA/Data/ ;i=10855')), ]) # Display results. for attributeDataResult in attributeDataResultArray: if attributeDataResult.Succeeded: print('AttributeData: ', attributeDataResult.AttributeData, sep='') else: print('*** Failure: ', attributeDataResult.ErrorMessageBrief, sep='') print() print('Finished.')
Copyright © 2004-2024 CODE Consulting and Development, s.r.o., Plzen. All rights reserved. Web page: www.opclabs.com
Documentation Home, Send Feedback. Resources: Knowledge Base, Product Downloads. Technical support: Online Forums, FAQ.Missing some example? Ask us for it on our Online Forums! You do not have to own a commercial license in order to use Online Forums, and we reply to every post.